package models

import (
	"gorm.io/gorm"
)

type User struct {
	gorm.Model
	Mobile    string `gorm:"type:char(11)"`
	Password  string `gorm:"type:char(32)"`
	NickName  string `gorm:"type:varchar(31)"`
	HeadImage string `gorm:"type:varchar(300)"`
}

func (u *User) FindByUserMobile(db *gorm.DB, mobile string) error {
	return db.Debug().Where("mobile=?", mobile).FirstOrCreate(u).Error
}

func (u *User) PasswordUpdates(db *gorm.DB) error {
	return db.Debug().Updates(u).Error
}

func (u *User) UserDel(db *gorm.DB, id int64) error {
	return db.Debug().Where("id=?", id).Delete(u).Error
}
